﻿
#ifndef  I_LOGIC_H
#define I_LOGIC_H

#include "GnsClientCoreHead.h"
#include <string>

class ILogic
{
public:
	ILogic();
	virtual  ~ILogic();

public:
	virtual bool init() = 0;

	// 连接结果的回调
	virtual void OnConnect(int iClientId, bool bConnect, int iReconnectCount, std::string  strErr) = 0;

	// 断线重连的回调
	virtual void OnReconnectAfterOffline(int iClientId, bool bConnect, int iReconnectCount, std::string  strErr) = 0;

	// 断线的回调
	virtual void OnClose(int iClientId) = 0;

	// 处理逻辑消息
	virtual int OnLogicMsg(int	iClientId, int iMainCode, int iSubCode, const char* pBody = nullptr, int iBodyLen = 0) = 0;

	// 销毁客户端完成后的回调
	virtual int onDestoryClient(int iClientId) = 0;

public:

	/* --------------------------------------------------------------------------
	函数说明：设置连接或断线重连时要转圈的参数
	传入参数：
		iStartCircleCountConnect,								OnConnect 状态下开始转圈的连接次数
		iEndCircleCountConnect,								OnConnect 状态下结束转圈的连接次数
		iStartCircleCountReconnectAfterOffline,	OnReconnectAfterOffline 状态下开始转圈的连接次数
		iEndCircleCountReconnectAfterOffline		OnReconnectAfterOffline 状态下结束转圈的连接次数)
	-------------------------------------------------------------------------- */
	void  setCircleParam(int  iStartCircleCountConnect, int  iEndCircleCountConnect, int  iStartCircleCountReconnectAfterOffline, int  iEndCircleCountReconnectAfterOffline);

public:
	int  _startCircleCountConnect=2;			// OnConnect 状态下开始转圈的连接次数
	int  _endCircleCountConnect=20;		// OnConnect 状态下结束转圈的连接次数

	int  _startCircleCountReconnectAfterOffline=5;		// OnReconnectAfterOffline 状态下开始转圈的连接次数
	int  _endCircleCountReconnectAfterOffline=30;				// OnReconnectAfterOffline 状态下结束转圈的连接次数

};

#endif